package com.gitee.minimalismstyle.fresh.simple.service.impl

import com.gitee.minimalismstyle.fresh.common.core.domain.QueryBody
import com.gitee.minimalismstyle.fresh.common.core.domain.QueryParams
import com.gitee.minimalismstyle.fresh.common.core.domain.R
import com.gitee.minimalismstyle.fresh.common.core.domain.Simple
import com.gitee.minimalismstyle.fresh.simple.api.service.SimpleListFieldService
import com.gitee.minimalismstyle.fresh.simple.api.service.SimpleListService
import com.gitee.minimalismstyle.fresh.simple.api.service.SimpleSqlService
import com.gitee.minimalismstyle.fresh.simple.dao.*
import org.beetl.sql.core.SQLManager
import org.springframework.beans.factory.annotation.Autowired

//@Primary
//@Service
class SimpleServiceImpl {
    @Autowired
    private lateinit var simpleListFieldService: SimpleListFieldService

    @Autowired
    private lateinit var simpleListService: SimpleListService

    @Autowired
    private lateinit var simpleSqlService: SimpleSqlService

    @Autowired
    private lateinit var simpleDatasourceDao: SimpleDatasourceDao

    @Autowired
    private lateinit var sm: SQLManager

    fun findListPageByCode(code: String, queryParams: QueryParams<Simple>): R<QueryBody<Simple>> {
        val simpleList = simpleListService.findByCode(code).get()
        var simpleSql = simpleSqlService.findById(simpleList.datasourceId!!.toLong()).get()
        return simpleSqlService.executePageBySimpleSql(simpleSql, queryParams)
    }

}